import pandas as pd

# 读取数据
df = pd.read_csv('data/stock.csv', usecols=['p_change'])
p_change = df['p_change']
# 自己指定分组区间
bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]
p_counts = pd.cut(p_change, bins)
# 得出one-hot编码矩阵
dummies = pd.get_dummies(p_counts, prefix="rise")
print(dummies)
